from selenium.webdriver.common.by import By

from base.base_action import BaseAction


# 直播管理页面
class LiveManagePage(BaseAction):

    # 直播管理按钮
    live_manage_btn = By.XPATH, "//span[text()='直播管理']"

    # 直播名称搜索框
    live_name_search = By.XPATH, "//input[@placeholder='搜索直播']"

    # 直播类型筛选框
    live_type_filter = By.XPATH, "//input[@placeholder='直播类型']"

    # 选择课程直播
    select_course_live = By.XPATH, "//li/span[text()='课程直播']"

    # 选择自定义直播
    select_custom_live = By.XPATH, "//li/span[text()='自定义直播']"

    # 组织形式筛选框
    organizational_form = By.XPATH, "//input[@placeholder='组织形式']"

    # 选择直接发起
    select_direct_initiation = By.XPATH, "//li/span[text()='直接发起']"

    # 选择间接发起
    select_indirect_initiation = By.XPATH, "//li/span[text()='学习项目']"

    # 状态筛选框
    status_filter = By.XPATH, "//input[@placeholder='状态']"

    # 选择未发布
    select_unpublished = By.XPATH, "//li/span[text()='未发布']"

    # 新建直播按钮
    add_live_btn = By.XPATH, "//span[contains(text(), '新增直播')]"

    # 直播名称输入框
    live_name_input = By.XPATH, "//input[@placeholder='请选择互动课程']"

    # 选择互动课程
    select_interaction_course = "document.getElementsByClassName('el-radio__inner')[61].click();"

    # 点击确定
    determine_btn1 = By.XPATH, "//div[2]/div/div[3]/div/div/button[1]/span"

    # 培训分类输入框
    train_sort_input = By.XPATH, "//input[@placeholder='请选择培训分类']"

    # 选择培训分类
    select_train_sort = By.XPATH, "//div[3]/div[1]/div[1]/div[1]/ul/li[1]/label/span[1]/span"

    # 选择空白区域
    select_blank_area = By.XPATH, "//div[1]/div/div[3]/div[3]/div/div[2]/main/div/main/div/div/div[1]/div"

    # 授课讲师输入框
    lecturer_input = By.XPATH, "//label[text()='授课讲师']/following-sibling::div//input"

    # 选择授课讲师
    select_lecturer = "document.getElementsByClassName('el-radio__inner')[59].click();"

    # 确定按钮
    determine_btn2 = By.XPATH, "//div[4]/div/div[3]/div/div/button[1]/span"

    # 小节名称输入框
    section_name_input = By.CSS_SELECTOR, ".jw-off-lep-contain > form > div > div:nth-child(2) > div:nth-child(1) input"

    # 直播日期输入框
    live_date_input = "document.getElementsByClassName('el-input__icon el-icon-date')[0].click();"

    # 选择日期
    select_date = "document.getElementsByClassName('next-month')[0].click();"

    # 直播开始/结束时间输入框
    live_start_time_input = By.XPATH, "//input[@placeholder='开始时间']"
    live_end_time_input = By.XPATH, "//input[@placeholder='结束时间']"

    # 选择直播开始/结束时间
    select_start_live_time = By.XPATH, "/html/body/div[5]/div[1]/div[1]/div/div[29]"
    select_end_live_time = By.XPATH, "/html/body/div[5]/div[1]/div[1]/div/div[30]"

    # 下一步按钮
    next_btn = By.XPATH, "//span[text()='下一步']"

    # 添加用户按钮
    add_user_btn = By.XPATH, " //span[contains(text(), '添加用户')]"

    # 选择用户
    select_all = "document.getElementsByClassName('el-checkbox__inner')[6].click();"

    # 确定按钮
    determine_btn4 = By.XPATH, "//div[5]/div/div[3]/div/button[1]/span"

    # 发布按钮
    publish_btn = By.XPATH, "//span[text()='保存并发布']"

    # 管理按钮
    manage_btn = "document.getElementsByClassName('operate-style')[1].click();"

    # 删除按钮
    remove_btn = By.XPATH, "//span[contains(text(), '删除直播')]"

    # 确定按钮
    determine_btn5 = By.XPATH, "//span[contains(text(), '确定')]"

    # 点击直播管理
    def click_live_manage_btn(self):
        return self.click(self.live_manage_btn)

    # 输入直播名称
    def input_live_name_search(self, content):
        return self.input(self.live_name_search, content)

    # 点击直播类型筛选框
    def click_live_type_filter(self):
        return self.click(self.live_type_filter)

    # 选择直播课程
    def click_select_course_live(self):
        return self.click(self.select_course_live)

    # 选择自定义直播
    def click_select_custom_live(self):
        return self.click(self.select_custom_live)

    # 点击组织形式筛选框
    def click_organizational_form(self):
        return self.click(self.organizational_form)

    # 选择直接发起
    def click_select_direct_initiation(self):
        return self.click(self.select_direct_initiation)

    # 选择间接发起
    def click_select_indirect_initiation(self):
        return self.click(self.select_indirect_initiation)

    # 点击状态筛选框
    def click_status_filter(self):
        return self.click(self.status_filter)

    # 选择未发布
    def click_select_unpublished(self):
        return self.click(self.select_unpublished)

    # 点击新建直播按钮
    def click_add_live_btn(self):
        return self.click(self.add_live_btn)

    # 点击直播名称输入框
    def click_live_name_input(self):
        return self.click(self.live_name_input)

    # 选择互动课程
    def click_select_interaction_course(self):
        return self.execute_js(self.select_interaction_course)

    # 点击确定按钮
    def click_determine_btn1(self):
        return self.click(self.determine_btn1)

    # 点击培训分类输入框
    def click_train_sort_input(self):
        return self.click(self.train_sort_input)

    # 选择培训分类
    def click_select_train_sort(self):
        return self.click(self.select_train_sort)

    # 点击空白区域
    def click_select_blank_area(self):
        return self.click(self.select_blank_area)

    # 点击授课讲师输入框
    def click_lecturer_input(self):
        return self.click(self.lecturer_input)

    # 选择授课讲师
    def click_select_lecturer(self):
        return self.execute_js(self.select_lecturer)

    # 点击确定按钮
    def click_determine_btn2(self):
        return self.click(self.determine_btn2)

    # 输入小节名称
    def input_section_name(self, content):
        return self.input(self.section_name_input, content)

    # 点击直播日期输入框
    def click_live_date_input(self):
        self.execute_js(self.live_date_input)
        return self.execute_js(self.select_date)

    # 选择直播开始时间
    def click_select_live_start_time(self):
        self.click(self.live_start_time_input)
        return self.click(self.select_start_live_time)

    # 选择直播结束时间
    def click_select_live_end_time(self):
        self.click(self.live_end_time_input)
        return self.click(self.select_end_live_time)

    # 点击下一步
    def click_next_btn(self):
        return self.click(self.next_btn)

    # 点击添加用户按钮
    def click_add_user_btn(self):
        return self.click(self.add_user_btn)

    # 点击全选
    def click_select_all(self):
        return self.execute_js(self.select_all)

    # 点击确定按钮
    def click_determine_btn4(self):
        return self.click(self.determine_btn4)

    # 点击发布按钮
    def click_publish_btn(self):
        return self.click(self.publish_btn)

    # 点击管理按钮
    def click_manage_btn(self):
        return self.execute_js(self.manage_btn)

    # 点击删除按钮
    def click_remove_btn(self):
        return self.click(self.remove_btn)

    # 点击确定按钮
    def click_determine_btn5(self):
        return self.click(self.determine_btn5)


